package cn.easthome.demo.day0060_pm;

import cn.easthome.demo.day0060_pm.util.GlobalUtil;

import java.io.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.annotation.*;

@WebServlet(name = "helloServlet", value = "/hello-servlet")
public class HelloServlet extends HttpServlet {


    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/html;charset=UTF-8");
        //获取系统时间
        long time = System.currentTimeMillis();
        //把系统时间转换成格式化字符串，响应给客户端
        String timeStr = GlobalUtil.getTime(time);
        //响应时间字符串
        response.getWriter().write(timeStr);

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}